from typing import *

from math import inf


class Solution:

    def countWays(self, nums: List[int]) -> int:
        cnt = Counter(nums)
        tot = ans = 0
        cnt[-1] = -1
        cnt[inf] = inf
        cnt = sorted(cnt.items(), key=lambda a: a[0])
        for i in range(1, len(cnt)):
            if tot > cnt[i - 1][0] and tot < cnt[i][0]:
                ans += 1
            tot += cnt[i][1]
        return ans


s = Solution()
print(s.countWays([6, 0, 3, 3, 6, 7, 2, 7]))
